package com.ruoyi.system.controller;

import com.ruoyi.system.domain.dto.MealVerifyDetailWrapperDTO;
import com.ruoyi.system.service.IMealVerifyDetailService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 核销情况明细接口
 * 前端路径：/meals/detailVerify
 */
@RestController
@RequestMapping("/meals")
@RequiredArgsConstructor
@Tag(name = "MealVerifyDetailController", description = "培训订餐核销明细")
public class MealVerifyDetailController {

    private final IMealVerifyDetailService mealVerifyDetailService;

    /**
     * 统一查询入口，根据传入参数自动路由到 4 个场景
     */
    @GetMapping("/detailVerify")
    @Operation(summary = "培训每日核销情况",
            description = "根据培训名称、区县、餐别组合查询每日已核销/未核销人数")
    public MealVerifyDetailWrapperDTO detailVerify(
            @Parameter(description = "培训名称（必填）", example = "新员工培训")
            @RequestParam String trainingName,

            @Parameter(description = "区县名称（可选）", example = "浔阳区分公司")
            @RequestParam(required = false) String dept,

            @Parameter(description = "餐别（可选：午餐/晚餐）", example = "午餐")
            @RequestParam(required = false) String mealType
    ) {
        return mealVerifyDetailService.queryDetails(trainingName, dept, mealType);
    }
    /**
     * 获取特定培训下的实际部门列表
     */
    @GetMapping("/depts")
    @Operation(summary = "获取培训涉及的部门列表",
            description = "根据培训名称获取实际参与该培训的部门列表")
    public List<String> listDeptsByTrainingName(
            @RequestParam(required = false)  String trainingName) {
        return mealVerifyDetailService.listDeptsByTrainingName(trainingName);
    }
}
